FROM alpine:3.17

MAINTAINER SkyworthOperator Team

ENV JAVA_HOME /usr/local/java/openjdk
ENV PATH $JAVA_HOME/bin:$PATH

# 设置默认编码为UTF-8
ENV LANG='zh_CN.UTF-8' LANGUAGE='zh_CN:zh' LC_ALL='zh_CN.UTF-8'

# 修改操作系统软件包源地址
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories

# 更新操作系统中的软件包
RUN apk update && apk upgrade

# 添加JAVA代码DEBUG工具
ADD tools /opt/tools

# 安装JDK运行所需的依赖包
RUN apk add --no-cache fontconfig libretls musl-locales musl-locales-lang ttf-dejavu tzdata zlib \
    && apk add --no-cache traceroute tini ca-certificates \
    && rm -rf /var/cache/apk/*

ENV JAVA_VERSION jdk8u362-b09

RUN set -eux; \
    ARCH="$(apk --print-arch)"; \
    case "${ARCH}" in \
       amd64|x86_64) \
         ESUM_URL='https://mirrors.skyworthdigital.com/operations/tools/OpenJDK/OpenJDK8U-jdk_x64_alpine-linux_hotspot_8u362b09.tar.gz.sha256'; \
         BINARY_URL='https://mirrors.skyworthdigital.com/operations/tools/OpenJDK/OpenJDK8U-jdk_x64_alpine-linux_hotspot_8u362b09.tar.gz'; \
         ;; \
       *) \
         echo "Unsupported arch: ${ARCH}"; \
         exit 1; \
         ;; \
    esac; \
	  wget ${BINARY_URL}; \
          wget ${ESUM_URL}; \
          sha256sum -c OpenJDK8U-jdk_x64_alpine-linux_hotspot_8u362b09.tar.gz.sha256; \
          mv OpenJDK8U-jdk_x64_alpine-linux_hotspot_8u362b09.tar.gz /tmp/openjdk.tar.gz; \
	  mkdir -p "$JAVA_HOME"; \
	  tar --extract \
	      --file /tmp/openjdk.tar.gz \
	      --directory "$JAVA_HOME" \
	      --strip-components 1 \
	      --no-same-owner \
	  ; \
    rm -f /tmp/openjdk.tar.gz ${JAVA_HOME}/src.zip;

RUN echo Verifying install ... \
    && echo javac -version && javac -version \
    && echo java -version && java -version \
    && echo Complete.

CMD ["java","-version"]
